'''
Created on 2012-9-5

@author: DANG Zhengfa
'''

import jinja2, os
from google.appengine.api import memcache

# template loader
templates_path = os.path.join(os.path.dirname(__file__), "templates")
jinja_environment = jinja2.Environment(
    loader=jinja2.FileSystemLoader(templates_path))

def render_template(template_file, template_values={}, client=None):
    # add http_logs to  template_values
    if template_values and client:
        template_values["http_logs"] = client.get_http_logs()
    
    template = jinja_environment.get_template(template_file)
    return template.render(template_values)

def dump(obj):
  for attr in dir(obj):
    print "obj.%s = %s" % (attr, getattr(obj, attr))
